<template>
  <view class="header">
    <view class="avatar image" @click="setAvatar">
      <u-avatar :src="user.avatar" size="150" v-if="user.av * 1 === 0"></u-avatar>
      <u-avatar :src="baseUrl + user.avatar" size="150" v-else></u-avatar>
    </view>
    <view class="info">
      <view class="nickname">{{user.nickname}}</view>
      <view class="mobile">{{user.mobile}}</view>
      <view class="level" v-if="user.level0">
        {{user.level0.display}}
        (ID: {{user.id}})
      </view>
    </view>
  </view>
</template>

<script>
import config from '../../../../config/config'

export default {
  props: ['user'],
  data() {
    return {
      baseUrl: config.baseUrl,
    }
  },
  methods: {
    // 修改头像
    setAvatar() {
      uni.navigateTo({
        url: '/sub_common/user/avatar'
      })
    },
  }
}

</script>

<style scoped lang="scss">
.header {
  height: 200rpx;
  margin-top: 40rpx;
  display: flex;
  align-items: center;
  padding: 0 20rpx;
  position: relative;
  .avatar {
    width: 150rpx;
    height: 150rpx;
    background: white;
    border-radius: 50%;
    overflow: hidden;
  }
  .info {
    padding-left: 20rpx;
    font-size: 30rpx;
    color: white;
    .mobile {
      margin: 7rpx 0;
    }
    .level {
      font-weight: 700;
      color: $main_color;
      background: white;
      padding: 6rpx 20rpx;
      border-radius: 20rpx;
      display: inline-block;
      //font-size: 24rpx;
    }
  }
}
</style>
